<!DOCTYPE HTML>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="console/header">
</head>
<body>
<section class="content">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title" th:text="密码修改"></h3>
                </div>
                <div class="box-body">
                    <form class="form-horizontal js-ajax-form" action="/console/admin/viewpwd" method="post" onsubmit="return checkLoginForm()">
                        <input type="hidden" name="uid" id="uid" th:value="${admin.uid}" />
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-10">
                                <input type="text" name="username" class="form-control" id="username" th:readonly="${!#strings.equals(admin.uid,null)}" th:value="${admin.username}" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="password" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="password" class="form-control" id="password" />
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password" class="col-sm-2 control-label">确认密码</label>
                            <div class="col-sm-10">
                                <input type="password"  class="form-control" id="password2" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default js-ajax-submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="console/footer"></div>

<script>
    function checkLoginForm() {
        var password = $('#password').val();
        var password2 = $('#password2').val();

        if(isNull(password)){
            layer.alert("请输入密码!!!");
            return false;
        }
        if(isNull(password2)){
            layer.alert("请输入确认密码!!!");
            return false;
        }
        if(password!=password2){
            layer.alert("两次输入的密码不一致!!!");
            return false;
        }

    }

    function isNull(input){
        if(input == null || input == '' || input == undefined){
            return true;
        }
        else{
            return false;
        }
    }
</script>
</body>
</html>